package com.imooc.controller;

import com.imooc.utils.RedisOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Author: 顾志杰
 * @Date: 2019/11/13
 * @Time: 9:33
 */


@RestController
@ApiIgnore
@RequestMapping("redis")
public class redisController {


    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private RedisOperator redisOperator;


    @GetMapping("/set")
    public Object set(String key,String value){
//        redisTemplate.opsForValue().set(key,value);
        redisOperator.set(key,value);
        return "OK";
    }

    @GetMapping("/get")
    public String get(String key){
        return redisOperator.get(key);
    }

    @GetMapping("/delete")
    public Object delete(String key){
//        redisTemplate.delete(key);
        redisOperator.del(key);
        return "OK";
    }
}
